﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace SHFST.Agents
{
   class Bullet : Agent
   {
      public float speed;
      public bool kill;
      private Point startPos;

      public void Load (Texture2D newTexture, Point newPos)
      {
         base.Load (newTexture, new Point (41, 35), new Point (3, 1), newPos);

         startPos = new Point (position.X, position.Y);
         kill = false;
      }

      public void Activate (bool active, Point newPos)
      {
         if (active)
         {
            speed = .5f;
            position = new Point (newPos.X, newPos.Y);
         }
         else
         {
            speed = 0;
            kill = false;
            position = new Point (startPos.X, startPos.Y);
         }
      }

      public override void Update (int elapsedTime)
      {
         if (position.X >= startPos.X)
         {
            Activate (false, Point.Zero);
            return;
         }

         base.Update (elapsedTime);

         position.X += (int)(speed * elapsedTime);
      }
   }
}
